home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
138
/
138.xpi
/
chrome
/
stumbleupon.jar
/
content
/
searchDialog.js
< prev
next >
Wrap
Text File
|
2009-05-22
|
2KB
|
111 lines
var detail = window.arguments[0];
var field_was_focused = false;
var old_tags_value = "";
function init()
{
var field = document.getElementById("field");
field.autocompleteDatasource =
{
getResults : function ()
{
var field = document.getElementById("field");
return opener.su_get_autocomplete_results(
"query",
field.value,
field.maxRows,
new Array());
}
}
field.value = detail.query_default;
}
function doOK()
{
var query = document.getElementById("field").value;
if (query == null)
return true;
/*
var error = opener.su_validate_tagstring(tags);
if (error != null)
{
alert(error);
document.getElementById("field").focus();
return false;
}
*/
if (query != '')
{
detail.query = query;
opener.document.getElementById("su_searchbox").value = query;
opener.setTimeout(
function(parent_window, detail){
parent_window.su_search_dialog_accept(detail);},
0,
opener,
detail);
}
return true;
}
function field_click_kludge(eventId)
{
// This handles value selection in the case where the user is
// clicking back and forth between tags and another field. Without
// this kludge, the text is selected only every second time. (ref:
// Firefox 1.5, XP) This may not be necessary on this window since
// the dialog has only one field, but it's here in case we need it
// later. -- JW
switch (eventId)
{
case "click":
var tags = document.getElementById('field');
var selected = (tags.value.length != 0)
&& ((tags.selectionEnd - tags.selectionStart) == tags.value.length);
if ((! field_was_focused) && (! selected))
{
tags.select();
}
field_was_focused = true;
break;
case "blur":
field_was_focused = false;
break;
}
return true;
}
function handle_field_focus(evt)
{
var tags = document.getElementById('field');
if (tags.value != "")
{
tags.select();
}
}
function handle_field_keyup(evt)
{
old_tags_value = document.getElementById("field").value;
return true;
}
function handle_field_textentered()
{
document.getElementById("stumble_search_dialog").acceptDialog();
}
function handle_field_textreverted()
{
document.getElementById("field").value = old_tags_value;
document.getElementById("field").select();
}